/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package MyClass;

import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

/**
 *
 * @author HuuTai_it
 */
public class GameWin extends Canvas{ 
    
    private GameManagement gameMng;
    private Image gameWin = Image.createImage("/MyPicture/gamewin.png");  
    
    public GameWin(GameManagement gameMng) throws Exception {
        
        this.gameMng = gameMng;
        setFullScreenMode(true);
    }
    
    public void paint(Graphics g) {

        g.drawImage(gameWin, 0, 0,  Graphics.TOP | Graphics.LEFT);
        
        g.setFont(Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_LARGE));
        
        g.setColor(255, 255, 255);
        
        g.drawString("Your Scores: " + String.valueOf(gameMng.control.scores), 120, 175, g.TOP | g.HCENTER);
    }
    
    public void keyPressed(int keyCode) {
        
        switch(getGameAction(keyCode)) {
                
            case FIRE:
                
                HighScoresSave hss = new HighScoresSave();
                try {
                    hss.updateHighScores(gameMng.control.scores);
                }
                catch(Exception ex){}
                gameMng.control.select();
                gameMng.control.showMainMenu();
                break;
        }        
    }    
}
